cmake_minimum_required(VERSION 2.8)
project(OCSample)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)

find_package(CUDA REQUIRED)
set(CUDA_USE_STATIC_CUDA_RUNTIME ON) #这一句解决 cannot find -lopencv_dep_cudart
set(CUDA_NVCC_FLAGS -gencode arch=compute_52,code=sm_52;-G;-g) # nvcc flags
include_directories(STATUS ${CUDA_INCLUDE_DIRS})
message(STATUS "CUDA头文件目录: ${CUDA_INCLUDE_DIRS}")

set(OpenCV_DIR "/usr/local/opencv341/share/OpenCV") # 指定OpenCV安装路径
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "OpenCV头文件目录: ${OpenCV_INCLUDE_DIRS}")

add_subdirectory(GpuMat)
add_subdirectory(PerElementAccess)
add_subdirectory(Stream)
add_subdirectory(Event)

file(GLOB CURRENT_HEADERS  *.h)
file(GLOB CURRENT_SOURCES  *.cu *.cpp)

CUDA_ADD_EXECUTABLE(${PROJECT_NAME} ${CURRENT_HEADERS} ${CURRENT_SOURCES})

target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS} ${CUDA_LIBRARIES})